/**
 * @description 用户注册和登录处理
 * @author 李哲
 */
const user = require('../model/User');

/**
 * 用户注册
 * @param {string} username 用户名
 * @param {string} password 密码
 */
const register = async (username, password) => {
    const newUser = await user.create({ username, password });
    return newUser
}
/**
 * 用户登录
 * @param {string} username 
 * @param {strong} password 
 * @returns 
 */
const login = async (username, password) => {
    const newUser = await user.findOne({
        username, password
    })
    if (newUser) {
        return true
    } else {
        return false
    }
}
module.exports = { register, login };